

#ifndef __FAT_FS_H__
#define __FAT_FS_H__


typedef struct _tag_fatfs {

	uint32_t sttlba;		/* 分区开始位置, 扇区单位. */
	uint32_t totals;        /* 分区内总的扇区数. */

	uint32_t clusiz;		/* sectors per cluster */
	
	uint32_t fatofs;		/* offset from PartitionStart */
	uint32_t fatsiz;		/* fat table sectors */
	
	uint32_t rdrofs;		/* offset from PartitionStart */
	uint32_t rdrsiz;		/* root directory sectors */
	
	uint32_t datofs;		/* offset from PartitionStart */

} fatfs_t;




int sdcard_read_single( uint32_t sidx, void * pary );

int fatfs_init( fatfs_t * pfatfs );
int fatfs_fstat( fatfs_t * pfatfs, const char * fname, uint32_t * psiz );
int fatfs_fread( fatfs_t * pfatfs, const char * fname, uint8_t * ptr );


uint32_t extract_bits(uint32_t value, int start_bit, int end_bit) ;
uint32_t pow(uint32_t base, uint32_t exp) ;

#endif

